package com.huike.pmps.controller;

import com.huike.pmps.model.entity.Member;
import com.huike.pmps.model.vo.Result;
import com.huike.pmps.service.*;
import com.huike.pmps.utils.TokenUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 作者：谌贵斌(黑桃K)
 * 日期: 2888-08-08
 * 老师QQ: 272488352
 * 官方QQ交流群: 377748272
 * 刀客程序员官网：http://www.daoke360.com
 * 刀客程序员淘宝旗舰店：https://daoke360.taobao.com/
 */
@RestController
@RequestMapping("/api/cockpit/provinces")
@Api(tags = "驾驶舱-省区")
public class CockpitProvinceController {

    @Autowired
    private CockpitProvinceService cockpitProvinceService;

    @ApiOperation(value = "新签和同数量及其金额", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "year", value = "年", paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "month", value = "月", paramType = "query", dataType = "int")
    })
    @GetMapping("/getNewSignData")
    public Result getNewSignData(HttpServletRequest request, Integer year, Integer month) {
        //从请求头中获取token
        Member member = (Member) request.getSession().getAttribute(TokenUtil.getToken(request));
        return cockpitProvinceService.selectNewSignData(member, year, month);
    }

    @ApiOperation(value = "产品销售金额数据", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "year", value = "年", paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "month", value = "月", paramType = "query", dataType = "int")
    })
    @GetMapping("/getProductNewSignContractAmount")
    public Result getProductContractAmount(HttpServletRequest request, Integer year, Integer month) {
        //从请求头中获取token
        Member member = (Member) request.getSession().getAttribute(TokenUtil.getToken(request));
        return cockpitProvinceService.selectProductNewSignContractAmount(member, year, month);
    }

    @ApiOperation(value = "周期回款情况", httpMethod = "GET")
    @GetMapping("/getPaymentCollectAmount")
    public Result getPaymentCollectAmount(HttpServletRequest request, Integer year) {
        //从请求头中获取token
        Member member = (Member) request.getSession().getAttribute(TokenUtil.getToken(request));
        return cockpitProvinceService.selectPaymentCollectAmount(member, year);
    }

    @ApiOperation(value = "运营毛利数据", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "year", value = "年", paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "month", value = "月", paramType = "query", dataType = "int")
    })
    @GetMapping("/getGrossProfit")
    public Result getGrossProfit(HttpServletRequest request, Integer year, Integer month) {
        //从请求头中获取token
        Member member = (Member) request.getSession().getAttribute(TokenUtil.getToken(request));
        return cockpitProvinceService.selectGrossProfit(member, year, month);
    }

    @ApiOperation(value = "运营财务数据", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "year", value = "年", paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "month", value = "月", paramType = "query", dataType = "int")
    })
    @GetMapping("/getFinance")
    public Result getFinance(HttpServletRequest request, Integer year, Integer month) {
        //从请求头中获取token
        Member member = (Member) request.getSession().getAttribute(TokenUtil.getToken(request));
        return cockpitProvinceService.selectFinance(member, year, month);
    }


    @ApiOperation(value = "战区销售商机数据", httpMethod = "GET")
    @GetMapping("/getBusinessOpportunities")
    public Result getBusinessOpportunities(HttpServletRequest request, Integer year, Integer month) {
        //从请求头中获取token
        Member member = (Member) request.getSession().getAttribute(TokenUtil.getToken(request));
        return cockpitProvinceService.selectBusinessOpportunities(member, year, month);
    }


    @ApiOperation(value = "30%以上商机", httpMethod = "GET")
    @GetMapping("/getBusinessOpportunitiesStage30")
    public Result getBusinessOpportunitiesStage30(HttpServletRequest request, Integer year, Integer month) {
        //从请求头中获取token
        Member member = (Member) request.getSession().getAttribute(TokenUtil.getToken(request));
        return cockpitProvinceService.selectBusinessOpportunitiesStage30(member, year, month);
    }

    @ApiOperation(value = "在线课程生成管理库存情况", httpMethod = "GET")
    @GetMapping("/getOnLineCourseStock")
    public Result getOnLineCourseStock(HttpServletRequest request) {
        //从请求头中获取token
        Member member = (Member) request.getSession().getAttribute(TokenUtil.getToken(request));
        return cockpitProvinceService.selectOnLineCourseStock(member);
    }

    @ApiOperation(value = "产能数据", httpMethod = "GET")
    @GetMapping("/getCourseCapacity")
    public Result getCourseCapacity(HttpServletRequest request) {
        //从请求头中获取token
        Member member = (Member) request.getSession().getAttribute(TokenUtil.getToken(request));
        return cockpitProvinceService.selectCourseCapacity(member);
    }
}
